<template>
    <div class="reportFormPage" v-if="show">
        <div class="report-dom">
            <el-row>
                <el-col :span="5" :offset="19">
                    <div class="pageNumBox">
                        <span>第</span>
                        <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
                        <span>页，共</span>
                        <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
                        <span>页</span>
                    </div>
                </el-col>
            </el-row>
            <div class="topTwoBox">
                <div class="centerName">{{ this.form.baobmc }}</div>
                <div class="codeText">
                    <tr v-for="(item, index) in form.baobbhList">{{ item }}</tr>
                </div>
            </div>
            <div class="threeTopBox">
                <div class="left-border">
                    <div class="box-title">检测单位名称：</div>
                    <div class>{{ form.jiancdwmc }}</div>
                </div>
                <div class="right-border">
                    <span>记录编号：</span>
                    <span class="placeholder">{{ form.jilbh }}</span>
                </div>
            </div>
            <!-- .........................1111111111111111111111111111111......................................................... -->
            <div class="table-border">
                <table height="220px" class="top-table">
                    <tbody>
                    <tr>
                        <td height="25" align="center" width="15%">
                            <span style="width: 90px; display: inline-block">工程名称</span>
                        </td>
                        <td width="35%" class="text-center">
                            <span>{{ form.gongcmc }}</span>
                        </td>
                        <td align="center" width="15%">
                            <span style="width: 90px; display: inline-block">工程部位/用途</span>
                        </td>
                        <td width="35%" class="text-center">
                            <span>{{ form.gongcbwyt }}</span>
                        </td>
                    </tr>
                    <tr>
                        <td height="50" align="center">样品信息</td>
                        <td class="specimen-border" colspan="3">
                            <span>样品名称：</span>
                            <span :class="{ 'placeholder': !form.yangpmc }">{{ form.yangpmc }}</span>
                            <span>；样品编号：</span>
                            <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                            <span>；样品数量：</span>
                            <span :class="{ 'placeholder': !form.yangpsl }">{{ form.yangpsl }}</span>
                            <span>；样品状态：</span>
                            <span :class="{ 'placeholder': !form.yangpzt }">{{ form.yangpzt }}</span>
                            <span>；来样时间：</span>
                            <span :class="{ 'placeholder': !form.yangpsj }">{{ form.yangpsj }}</span>
                        </td>
                    </tr>
                    <tr>
                        <td height="25" align="center" width="15%">
                            <span style="width:90px;display:inline-block">试验检测日期</span>
                        </td>
                         <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->                                            
 <td width="35%" class="text-center">
      <el-input v-model="form.shiyjcrq" />
</td>
                        <td align="center" width="15%">
                            <span style="width:90px;display:inline-block">试验条件</span>
                        </td>
                        <td v-if="isPdf" width="35%">
                            温度：
                            <span style="display: inline-block; width: 10%;">{{ form.shiytjwd }}</span>
                            ℃；湿度：
                            <span style="display: inline-block; width: 10%;">{{ form.shiytjsd }}</span>%RH
                        </td>
                        <td v-else width="35%">
                            温度：
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" class="height100"
                                      style="width: 15%"/>
                            ℃；湿度：
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" class="height100"
                                      style="width: 15%"/>
                            %RH
                        </td>
                    </tr>
                    <tr>
                        <td height="50" align="center" width="15%">
                            <span style="width: 90px; display: inline-block">检测依据</span>
                        </td>
                        <td width="35%">
                            <span v-if="isPdf">{{ form.jiancyj }}</span>
                            <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark"
                                      @dblclick.native="showBsJiancyjView" readonly/>
                        </td>
                        <td align="center" width="15%">
                            <span style="width: 90px; display: inline-block">判定依据</span>
                        </td>
                        <td width="35%">
                            <span v-if="isPdf">{{ form.pandyj }}</span>
                            <el-input v-else type="textarea" v-model="form.pandyj" :rows="2"
                                      @dblclick.native="showBsJudgeBaseView"
                                      @focus="handleFocus('pandyj')" class="mark"/>
                        </td>
                    </tr>
                    <tr class="bottom-border">
                        <td height="50" align="center">
                            <div>主要仪器设备</div>
                            <div>名称及编号</div>
                        </td>
                        <td colspan="3">
                            <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                            <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh"
                                      class="height100 width100 mark"
                                      @dblclick.native="showBsInstrumentView" readonly></el-input>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!-- .................................22222222222222222222222222222222............................................... -->
                <table height="516px" class="middle-table">
                    <tbody>
                    <tr>
                        <td colspan="7" height="28">砂当量试验</td>
                    </tr>
                    <tr>
                        <td width="25%" colspan="2" rowspan="2">配置冲洗液</td>
                        <td width="15%" height="28">配置时间</td>
                        <td width="15%">氯化钙用量（g）</td>
                        <td width="15%">甘油用量（g）</td>
                        <td width="15%">甲醛用量（g）</td>
                        <td width="15%">配置数量（L）</td>
                    </tr>
                    <tr>
                        <td width="15%" height="28">
                            <span v-if="isPdf">{{ form.shadlPzsj }}</span>
                            <el-date-picker v-else v-model="form.shadlPzsj" class="hide-icon width100" type="date"
                                            format="yyyy年MM月dd日" value-format="yyyy年MM月dd日"></el-date-picker>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.shadlLhg"
                                      @keydown.native="handleKeyDown($event, 0, 0)" :ref="'0_0'"/>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.shadlGy"
                                      @keydown.native="handleKeyDown($event, 0, 1)" :ref="'0_1'"/>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.shadlJq"
                                      @keydown.native="handleKeyDown($event, 0, 2)" :ref="'0_2'"/>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.shadlPzsl"
                                      @keydown.native="handleKeyDown($event, 0, 3)" :ref="'0_3'"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="10%">试验次数</td>
                        <td width="15%">试样湿质量m<sub>1</sub>(g)</td>
                        <td width="15%">试筒中絮凝物和沉淀物的总高度h<sub>1</sub>(mm)</td>
                        <td width="15%">试筒中用活塞测定的集料沉淀物的高度h<sub>2</sub>(mm)</td>
                        <td width="15%">冲洗液温度(℃)</td>
                        <td width="15%">试样砂当量测值(%)</td>
                        <td width="15%">试样砂当量测定值(%)</td>
                    </tr>
                    <tr>
                        <td height="28">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.shadlSycs1"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.shadlSzl1"
                                      @keydown.native="handleKeyDown($event, 1, 0)"
                                      @paste.native="handlePaste($event, 0, 0)"
                                      :ref="'1_0'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.shadlH11"
                                      @change="calculateShadlCz(1)"
                                      @keydown.native="handleKeyDown($event, 1, 1)"
                                      @paste.native="handlePaste($event, 0, 1)"
                                      :ref="'1_1'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.shadlH21"
                                      @change="calculateShadlCz(1)"
                                      @keydown.native="handleKeyDown($event, 1, 2)"
                                      @paste.native="handlePaste($event, 0, 2)"
                                      :ref="'1_2'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.shadlWd1"
                                      @keydown.native="handleKeyDown($event, 1, 3)"
                                      @paste.native="handlePaste($event, 0, 3)"
                                      :ref="'1_3'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.shadlCz1"
                                      disabled/>
                        </td>
                        <td rowspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.shadlPjz"
                                      disabled/>
                        </td>
                    </tr>
                    <tr>
                        <td height="28">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.shadlSycs2"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.shadlSzl2"
                                      @keydown.native="handleKeyDown($event, 2, 0)"
                                      @paste.native="handlePaste($event, 1, 0)"
                                      :ref="'2_0'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.shadlH12"
                                      @change="calculateShadlCz(2)"
                                      @keydown.native="handleKeyDown($event, 2, 1)"
                                      @paste.native="handlePaste($event, 1, 1)"
                                      :ref="'2_1'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.shadlH22"
                                      @change="calculateShadlCz(2)"
                                      @keydown.native="handleKeyDown($event, 2, 2)"
                                      @paste.native="handlePaste($event, 1, 2)"
                                      :ref="'2_2'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.shadlWd2"
                                      @keydown.native="handleKeyDown($event, 2, 3)"
                                      @paste.native="handlePaste($event, 1, 3)"
                                      :ref="'2_3'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.shadlCz2"
                                      disabled/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="7" height="28">亚甲蓝试验</td>
                    </tr>
                    <tr>
                        <td width="25%" colspan="2" rowspan="2">标准亚甲蓝溶液配制</td>
                        <td width="15%">烘干前亚甲蓝粉末质量mh(g)</td>
                        <td width="15%">烘干后亚甲蓝粉末质量mg(g)</td>
                        <td width="15%">亚甲蓝粉末含水率(%)</td>
                        <td width="30%" colspan="2">配置1L标准溶液所需亚甲蓝粉末质量(g)</td>
                    </tr>
                    <tr>
                        <td height="28">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.yajlZlmh"
                                      @change="calculateYajlHsl()"
                                      @keydown.native="handleKeyDown($event, 3, 0)"
                                      @paste.native="handlePasteTwo($event, 0, 0)"
                                      :ref="'3_0'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.yajlZlmg"
                                      @change="calculateYajlHsl()"
                                      @keydown.native="handleKeyDown($event, 3, 1)"
                                      @paste.native="handlePasteTwo($event, 0, 1)"
                                      :ref="'3_1'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.yajlHsl"
                                      disabled/>
                        </td>
                        <td colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.yajlZl1l"
                                      disabled/>
                        </td>
                    </tr>
                    <tr>
                        <td width="25%" height="28" colspan="2" rowspan="3">亚甲蓝吸附量的测定</td>
                        <td width="15%" height="28">测定指标</td>
                        <td width="15%">烘干试样质量(g)</td>
                        <td width="15%">试验加入亚甲蓝溶液总量(mL)</td>
                        <td width="30%" colspan="2">亚甲蓝值(g/kg)</td>
                    </tr>
                    <tr>
                        <td width="15%" height="28">亚甲蓝值</td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.yajlCdzmg"
                                      @change="calculateYajlCdzg(1)"
                                      @keydown.native="handleKeyDown($event, 4, 0)"
                                      @paste.native="handlePasteTwo($event, 1, 0)"
                                      :ref="'4_0'"/>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.yajlCdzml"
                                      @change="calculateYajlCdzg(1)"
                                      @keydown.native="handleKeyDown($event, 4, 1)"
                                      @paste.native="handlePasteTwo($event, 1, 1)"
                                      :ref="'4_1'"/>
                        </td>
                        <td width="30%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.yajlCdzg"
                                      disabled/>
                        </td>
                    </tr>
                    <tr>
                        <td width="15%" height="28">小于0.15mm部分或矿粉亚甲蓝值</td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.yajlX015mg"
                                      @change="calculateYajlCdzg(2)"
                                      @keydown.native="handleKeyDown($event, 5, 0)"
                                      @paste.native="handlePasteTwo($event, 2, 0)"
                                      :ref="'5_0'"/>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.yajlX015ml"
                                      @change="calculateYajlCdzg(2)"
                                      @keydown.native="handleKeyDown($event, 5, 1)"
                                      @paste.native="handlePasteTwo($event, 2, 1)"
                                      :ref="'5_1'"/>
                        </td>
                        <td width="30%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.yajlX015g"
                                      disabled/>
                        </td>
                    </tr>
                    <tr>
                        <td width="25%" colspan="2" rowspan="2">亚甲蓝快速评价试验</td>
                        <td width="15%" height="28">烘干试样质量m(g)</td>
                        <td width="30%" colspan="2">试验加入亚甲蓝溶液总量V(mL)</td>
                        <td width="30%" colspan="2">滤纸上沉淀物周围是否出现色晕</td>
                    </tr>
                    <tr>
                        <td width="15%" height="28">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.yajlPjmg"
                                      @change="calculateYajlPjml()"
                                      @keydown.native="handleKeyDown($event, 6, 0)"
                                      @paste.native="handlePasteTwo($event, 3, 0)"
                                      :ref="'6_0'"/>
                        </td>
                        <td width="30%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.yajlPjml"
                                      disabled/>
                        </td>
                        <td width="30%" colspan="2">
                            <el-input tabindex="200"
                                      v-model="form.yajlPjlz"
                                      @keydown.native="handleKeyDown($event, 6, 1)"
                                      @paste.native="handlePasteTwo($event, 3, 1)"
                                      :ref="'6_1'"/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="7" height="28">棱角性试验（流动时间法）</td>
                    </tr>
                    <tr>
                        <td width="10%">试验次数</td>
                        <td width="15%">细集料表观相对密度</td>
                        <td width="30%" colspan="2">洗去小于0.075mm颗粒的干试样质量m(g)</td>
                        <td width="15%">细集料从漏斗开口处流出时间测值(s)</td>
                        <td width="30%" colspan="2">细集料流动时间测定值(s)</td>
                    </tr>
                    <tr>
                        <td width="10%" height="28">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjSycs1"/>
                        </td>
                        <td width="15%" rowspan="5">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjMd1"
                                      @change="calculateLengjMg()" @keydown.native="handleKeyDown($event, 7, 0)"
                                      :ref="'7_0'"/>
                        </td>
                        <td width="30%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjMg1"
                                      disabled/>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjCz1"
                                      @change="calculateLengjPjz()" @keydown.native="handleKeyDown($event, 7, 1)"
                                      :ref="'7_1'"/>
                        </td>
                        <td width="30%" colspan="2" rowspan="5">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjPjz"
                                      disabled/>
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" height="28">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjSycs2"/>
                        </td>
                        <td width="30%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjMg2"
                                      disabled/>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjCz2"
                                      @change="calculateLengjPjz()" @keydown.native="handleKeyDown($event, 8, 1)"
                                      :ref="'8_1'"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" height="28">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjSycs3"/>
                        </td>
                        <td width="30%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjMg3"
                                      disabled/>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjCz3"
                                      @change="calculateLengjPjz()" @keydown.native="handleKeyDown($event, 9, 1)"
                                      :ref="'9_1'"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" height="28">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjSycs4"/>
                        </td>
                        <td width="30%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjMg4"
                                      disabled/>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjCz4"
                                      @change="calculateLengjPjz()" @keydown.native="handleKeyDown($event, 10, 1)"
                                      :ref="'10_1'"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" height="28">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjSycs5"/>
                        </td>
                        <td width="30%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjMg5"
                                      disabled/>
                        </td>
                        <td width="15%">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.lengjCz5"
                                      @change="calculateLengjPjz()" @keydown.native="handleKeyDown($event, 11, 1)"
                                      :ref="'11_1'"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!-- .....................................................33333333333333333................................................... -->
                <table height="60px" class="bottom-table">
                    <tr>
                        <td>
                            <el-input type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')"/>
                        </td>
                    </tr>
                </table>
            </div>
            <!-- .................................44444444444............................................. -->
            <table height="22px" class="transparent">
                <tbody>
                <tr>
                    <td width="10%" align="right">检测：</td>
                    <td width="15%" align="left">
                        <!-- {{this.form.jiancr}} -->
                    </td>
                    <td width="10%" align="right">记录：</td>
                    <td width="15%" align="left">
                        <!-- {{this.form.jilr}} -->
                    </td>
                    <td width="10%" align="right">复核：</td>
                    <td align="left" width="15%">
                        <!-- {{this.form.fuhr}} -->
                    </td>
                    <td width="10%">日期：</td>
                    <td align="left" width="15%">
                        <div style="display: inline-block; margin-right: 30px;">年</div>
                        <div style="display: inline-block; margin-right: 30px;">月</div>
                        <div style="display: inline-block;">日</div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
        <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
        <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
    </div>
</template>

<script>
import {handleFocus, emptyConvert, calculateMeanvalue, handleKeyDown, handlePaste} from "@/views/reportForms/utils";
import decimal from "@/utils/big-decimal";
import Bus from "@/utils/bus";
import {getXjlsdljlbBsInfo} from "@/api/report_jl/xjl";
import {computeBiQualification} from "@/api/sycs/biQualification";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";

export default {
    name: "xjlsdljlb",
    components: {
        BsInstrumentView,
        BsJiancyjView,
        BsJudgeBaseView
    },
    props: {
        excelId: {
            type: [String, Number],
            default: () => ""
        },
        syType: {
            type: [String, Number],
            default: () => ""
        },
        page: {
            type: Number,
            default: () => 0
        },
        isPdf: {
            type: Boolean,
            default: () => false
        },
        printEmpty: {
            type: Boolean,
            default: () => false
        }
    },
    data() {
        return {
            form: {
                detailList: [],
                baobbhList: []
            },
            backBgz: {},
            show: false
        };
    },
    watch: {
        isPdf(newVal, oldVal) {
            this.form = {...emptyConvert(this.form, newVal)};
        },
        backBgz: {
            deep: true,
            immediate: true,
            handler(newVal, oldVal) {
                this.backBgzFun();
            }
        }
    },
    created() {
        this.init();
    },
    methods: {
        // 根据报表id获取当前报表信息
        init() {
            this.show = false;
            getXjlsdljlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
                this.form = response.data;
                this.setInitialValue();
                this.show = true;
                if (!this.form.fujsm) {
                    this.form.fujsm = "附加声明：";
                }
            });
        },
        // 设置初始值
        setInitialValue() {
            if (this.form) {
                this.form.baobmc = this.form.baobmc || "细集料砂当量、亚甲蓝、棱角性试验检测记录表";
                this.form.baobbh = this.form.baobbh || "JGLQ02021,JGLQ02022,JGLQ02024a";
                this.$set(this.form, "baobbhList", []);
                this.form.baobbhList = ["JGLQ02021", "JGLQ02022", "JGLQ02024a"];
                this.form.shadlSycs1 = "1";
                this.form.shadlSycs2 = "2";
                this.form.lengjSycs1 = "1";
                this.form.lengjSycs2 = "2";
                this.form.lengjSycs3 = "3";
                this.form.lengjSycs4 = "4";
                this.form.lengjSycs5 = "5";
            }
        },
        // 显示检测依据列表
        showBsJiancyjView() {
            this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
        },
        // 检测依据选择
        selectJiancyj(info) {
            this.form.jiancyj = info.label;
            this.form.jiancyjIds = info.ids;
            Bus.$emit("setXjlBgJiancyj", {jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds});
        },
        // 显示判定依据列表
        showBsJudgeBaseView() {
            this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
        },
        // 判断依据选择
        selectJudge(info) {
            if (!this.form.pandyj) {
                this.form.pandyj = info.label;
                return;
            }
            if (info && info.label) {
                this.form.pandyj += "、" + info.label;
            }
        },
        // 显示仪器列表
        showBsInstrumentView() {
            this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
        },
        // 仪器选择
        selectInstrument(info) {
            this.form.zhuyyqsbmcjbh = info.label;
            this.form.shebIds = info.ids;
        },
        // 计算试样沙当量测值
        calculateShadlCz(index) {
            // 100*B/A
            const A = this.form["shadlH1" + index];
            const B = this.form["shadlH2" + index];
            let C = null;
            if (A && B) {
                C = decimal.divide(decimal.multiply(100, B), A, 0);
            }
            this.form["shadlCz" + index] = C;
            this.calculateShadlPjz();
        },
        // 计算试样砂当量测定值(平均值)
        calculateShadlPjz() {
            let arr = [];
            if (this.form.shadlCz1) {
                arr.push(this.form.shadlCz1);
            }
            if (this.form.shadlCz2) {
                arr.push(this.form.shadlCz2);
            }
            this.form.shadlPjz = calculateMeanvalue(arr, 0);
            this.backBgzFun();
        },
        // 计算亚甲蓝粉末含水率(%)
        calculateYajlHsl() {
            // C=100*(A-B)/B
            const A = this.form.yajlZlmh;
            const B = this.form.yajlZlmg;
            let C = null;
            if (A && B) {
                C = decimal.divide(decimal.multiply(100, decimal.subtract(A, B)), B);
            }
            this.form.yajlHsl = C;
            // 配置1L标准溶液所需亚甲蓝粉末质量(g)  10*(1+0.01*C)
            if (C) {
                this.form.yajlZl1l = decimal.multiply(10, decimal.multiply(1, decimal.multiply(0.01, C, 8), 8));
            } else {
                this.form.yajlZl1l = null;
            }
            this.calculateYajlPjml();
        },
        // 计算亚甲蓝值
        calculateYajlCdzg(index) {
            // 10*B/A
            const A = index == 1 ? this.form.yajlCdzmg : this.form.yajlX015mg;
            const B = index == 1 ? this.form.yajlCdzml : this.form.yajlX015ml;
            let C = null;
            if (A && B) {
                C = decimal.divide(decimal.multiply(10, B), A, 1);
            }
            index == 1 ? (this.form.yajlCdzg = C) : (this.form.yajlX015g = C);
            this.calculateYajlPjz();
        },
        // 计算亚甲蓝平均值
        calculateYajlPjz() {
            let yajlPjz = null;
            let arr = [];
            if (this.form.yajlCdzg) {
                arr.push(this.form.yajlCdzg);
            }
            if (this.form.yajlX015g) {
                arr.push(this.form.yajlX015g);
            }
            if (arr.length > 0) {
                yajlPjz = calculateMeanvalue(arr, 1);
            }
            this.form.yajlPjz = yajlPjz;
            this.backBgzFun();
        },
        // 计算试验加入亚甲蓝溶液总量
        calculateYajlPjml() {
            // (1.4*E/10)*100/(100+w2） w2 = 亚甲蓝粉末含水率
            const E = this.form.yajlPjmg;
            const w2 = this.form.yajlHsl;
            let num = null;
            if (E && w2) {
                num = decimal.multiply(decimal.divide(decimal.multiply(1.4, E), 10, 8), 100);
                num = decimal.divide(num, decimal.add(100, w2), 0);
            }
            this.form.yajlPjml = num;
        },
        // 洗去小于0.075mm颗粒的干试样质量m(g)
        calculateLengjMg() {
            //  A=1000*K/(2.7*D)   D =1
            const K = this.form.lengjMd1;
            let A = null;
            if (K) {
                A = decimal.divide(decimal.multiply(1000, K), 2.7, 1);
            }
            for (let index = 1; index <= 5; index++) {
                this.form["lengjMg" + index] = A;
            }
        },
        // 计算细集料流动时间测定值 - 平均值
        calculateLengjPjz() {
            let arr = [];
            for (let index = 1; index <= 5; index++) {
                const num = this.form["lengjCz" + index];
                if (num) {
                    arr.push(num);
                }
            }
            this.form.lengjPjz = calculateMeanvalue(arr);
            this.backBgzFun();
        },
        // 返回报告引入值
        backBgzFun() {
            Bus.$emit("setXjlBgJiancjg", [
                {key: 60, value: this.form.shadlPjz}, // 砂当量
                {key: 63, value: this.form.yajlPjz}, // 亚甲蓝
                {key: 62, value: this.form.yajlPjz} // 棱角性
            ]);
        },
        submitForm() {
            return this.form;
        },
        handleFocus(event) {
            handleFocus(event, this.page, this.form[event]);
        },
        handleKeyDown(event, rowIndex, colIndex) {
            const maxArr = [3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1]; // 每一行最多有多少可聚焦输入框（从0开始）
            const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
            const arr = ref.split("_");
            if (arr[0] > 7 && arr[1] == 0) {
                this.handleKeyDown(event, arr[0], arr[1]);
                return;
            }
            if (this.$refs[ref]) {
                this.$refs[ref].focus();
            }
        },
        // 粘贴赋值方法
        handlePaste(event, rowIndex, colIndex) {
            const nameAllArr = [
                ["shadlSzl1", "shadlH11", "shadlH21", "shadlWd1"],
                ["shadlSzl2", "shadlH12", "shadlH22", "shadlWd2"],
            ];
            const subscriptArr = [
                [0, 1, 2, 3],
                [0, 1, 2, 3],
            ];

            const methodsAllArr = [
                [null, "calculateShadlCz", "calculateShadlCz", null],
                [null, "calculateShadlCz", "calculateShadlCz", null],
            ];
            const parameterArr = [
                [null, 1, 1, null],
                [null, 2, 2, null],
            ];
            const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
            const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
            for (let a = 0; a < nameSetArr.length; a++) {
                for (let b = 0; b < nameSetArr[a].length; b++) {
                    this.form[nameSetArr[a][b]] = cols[a][b];
                }
            }
            for (let a = 0; a < methodsSetArr.length; a++) {
                for (let b = 0; b < methodsSetArr[a].length; b++) {
                    if (methodsSetArr[a][b]) {
                        this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
                    }
                }
            }
        },

        // 粘贴赋值方法
        handlePasteTwo(event, rowIndex, colIndex) {
            const nameAllArr = [
                ["yajlZlmh", "yajlZlmg"],
                ["yajlCdzmg", "yajlCdzml"],
                ["yajlX015mg", "yajlX015ml"],
                ["yajlPjmg", "yajlPjlz"],
            ];
            const subscriptArr = [
                [0, 1],
                [0, 1],
                [0, 1],
                [0, 1],
            ];

            const methodsAllArr = [
                ["calculateYajlHsl", "calculateYajlHsl"],
                ["calculateYajlCdzg", "calculateYajlCdzg"],
                ["calculateYajlCdzg", "calculateYajlCdzg"],
                ["calculateYajlPjml", null],
            ];
            const parameterArr = [
                [null, null],
                [1, 1],
                [2, 2],
                [null, null],
            ];
            const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
            const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
            for (let a = 0; a < nameSetArr.length; a++) {
                for (let b = 0; b < nameSetArr[a].length; b++) {
                    this.form[nameSetArr[a][b]] = cols[a][b];
                }
            }
            for (let a = 0; a < methodsSetArr.length; a++) {
                for (let b = 0; b < methodsSetArr[a].length; b++) {
                    if (methodsSetArr[a][b]){
                        this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
                    }
                }
            }
        },

        // 计算方法调用
        setCalculate(name, a, b, c, d, e) {
            this[name](a, b, c, d, e);
        }
    }
};
</script>

<style scoped lang="scss"></style>
